package com.itheima.idea;

import java.util.Scanner;

public class Test3Array {
    public static void main(String[] args) {
        Scanner sc =new Scanner(System.in);
        int[] arr = new int[5];
        for (int i = 0; i < arr.length; i++) {
            System.out.println("请输入第" + (i+1) +"个数据");
            int num = sc.nextInt();
        //  对录入的数据进行判断
           if(num >100 || num <50){
               System.out.println("本次录入的数据不在50-100之间请重新输入");
               i--;
           }else{

              arr[i] = num;
           }
        }
        int sum = 0;
        for (int i = 0; i < arr.length; i++) {
            sum += arr[i];
        }
        System.out.println("sum:" + sum);
    }
}
